<template>
  <div class="page">
    <titleVue :title="'提现时间配置'"></titleVue>
    <div class="main">
      <el-form ref="form" :model="form" :rules="rules" label-width="121px">
        <el-form-item label="提现时间范围" prop="withdrawTime">
          <el-input style="width: 220px;"  v-model="form.withdrawTime"
            onkeyup="value=value.replace(/[^\d]/g,'')">
            <template slot="suffix">
              <div class="suffixText">天</div>
            </template>
          </el-input>
        </el-form-item>
        
      </el-form>
    </div>
    <div class="BtnBox">
      <button class="submitBtn" @click="saveEvent">保存</button>
    </div>
  </div>
</template>

<script>
import titleVue from '@/components/titleVue.vue'
import httpApi from '@/http';
export default {
  data() {
    return {
      form: {
        withdrawTime: '',
      },
      rules: {
        withdrawTime: [
          { required: true, message: '请选择提现时间', trigger: 'change' }
        ],
      },
      cid:''

    }
  },
  mounted(){
    this.getData()
  },
  methods: {
    getData(){
      let params={}
          httpApi.basicSettingApi.getWithdrawTime(params).then((res) => {
            console.log(res.data)
              this.cid=res.data.data.cid
              this.form.withdrawTime=res.data.data.automaticTime
          });
    },
    saveEvent() {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          let params={
            automaticTime:this.form.withdrawTime,
            type:1,
            cid:this.cid
          }
          httpApi.basicSettingApi.updateWithdrawTime(params).then((res) => {
             if(res.data.code==200){
               this.$message.success('保存成功')
               this.getData
             }
          });
        } else {
          this.$message.error('请填写完整信息')
          return false;
        }
      });
    },
  },
  components: {
    titleVue
  }
}
</script>

<style lang="scss" scoped>
.page {
  height: 100vh;
  height: calc(100vh - 191px);
  padding: 30px;
  position: relative;
}

.main {
  background-color: #fff;
  .suffixText {
    font-size: 12px;
    font-family: PingFang SC;
    font-weight: 400;
    color: #CCCCCC;
    text-align: center;
    line-height: 40px;

    padding-right: 10px;
  }
}

.BtnBox {
  width: 100%;
  padding: 20px;
  display: flex;
  justify-content: center;
  position: absolute;
  bottom: 0;

  .submitBtn {
    cursor: pointer;
    height: 36px;
    border-radius: 4px;
    background-color: #1890FF;
    width: 80px;
    color: #fff;
    font-size: 12px;
    transition: 0.2s;

    &:hover {
      opacity: 0.8;
    }
  }
}
</style>